package com.njy.cloudalibaba.consumer.interceptor;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

public class test {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(4,10,4, TimeUnit.SECONDS,new ArrayBlockingQueue<>(3),
                new ThreadPoolExecutor.DiscardOldestPolicy());

        AtomicInteger integer = new AtomicInteger(0);

            threadPoolExecutor.execute(new Runnable() {
                @Override
                public void run() {
                    for (int i =0 ;i<50 ;i++){
                    System.out.println(Thread.currentThread().getName());
                    integer.incrementAndGet();
                    }
                }
            });



        try {
            Thread.sleep(5000);
            System.out.println(integer.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


    }
}
